home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / SRC / STARTUP / C0C1.ASM < prev    next >
Assembly Source File  |  1997-07-08  |  1KB  |  78 lines

  1. ;common file #1
  2.  
  3. ;included by c0.asm
  4.  
  5. ;setup _argv & _argstr
  6.   mov esi,_psp
  7.   add esi,80h
  8.   mov edi,offset _argstr
  9.   lodsb  ;al=size!
  10. ;  ch=flag:start of new arg?
  11. ;  cl=flag:inside ""
  12.   xor ecx,ecx
  13.   mov edx,1
  14.   and al,7fh ;ensure no error
  15.   jz done
  16.   mov ebx,_argv  ;the [_argv+0] = file name (set later)
  17.   add ebx,4
  18.  
  19. @@1:
  20.   cmp byte ptr[esi],'"'
  21.   jz quote
  22.   .if !cl     ;check only if we are not in quotes
  23.     cmp byte ptr[esi],32   ;seperators
  24.     jz @f
  25.     cmp byte ptr[esi],9
  26.     jz @f
  27.     cmp byte ptr[esi],255
  28.     jz @f
  29.   .endif
  30.   or ch,ch
  31.   jnz notnew
  32. ;new string
  33.   inc ch          ;set flag:inside string (arg)
  34.   inc edx
  35.   mov [ebx],edi
  36.   add ebx,4
  37. notnew:
  38.   movsb
  39.   dec al
  40.   jz done
  41.   jmp @@1
  42. quote:
  43.   .if cl
  44.     xor cl,cl
  45.   .else
  46.     inc cl
  47.   .endif
  48.   inc esi
  49.   dec al
  50.   jz done
  51.   jmp @@1
  52. @@:
  53.   .if ch
  54.     xor ch,ch      ;clear flag:not at start
  55.     mov byte ptr [edi],0
  56.     inc edi
  57.   .endif
  58.   inc esi
  59.   dec al
  60.   jz done
  61.   jmp @@1
  62. done:
  63.   mov byte ptr [edi],0
  64.   mov dptr _argc,edx
  65.  
  66.   mov esi,_environ
  67. ;search for double 0
  68.   dec esi
  69. @@:
  70.   inc esi
  71.   cmp word ptr[esi],0
  72.   jnz @b
  73.   add esi,4  ;skip 0/0/word
  74.   mov _filename,esi
  75.   mov ebx,_argv
  76.   mov [ebx+0],esi
  77.  
  78.